<?php

class TestData extends Controller
{
	function TestData() 
	{
		parent::Controller();
	}
	
	
	public function test()
	{
		$t1 = $now = time();
		$t2 = strtotime("midnight");
		$t3 = strtotime("midnight -1 day");
		$t4 = strtotime("midnight -1 month", $now);

		echo date('d-m-Y H:i:s', $t1);
		echo '<br/>';
		echo date('d-m-Y H:i:s', $t2);
		echo '<br/>';
		echo date('d-m-Y H:i:s', $t3);
		echo '<br/>';
		echo date('d-m-Y H:i:s', $t4);
		
		//$query = $this->db->query('select * from t');
		//foreach($query->result() as $row)
		//{
			
		//}
	}
	
	
	/*
	 * Load test data in the database for benchmarking
	 */
	public function load()
	{
		
		/*
		for($i=0; $i<150000; $i++)
		{
			$user_id = rand(1, 1000);
			$dt = time() + $i; // set different time for each task to test index cardinality
			$sql = "INSERT INTO enctask 
					VALUES(null, $user_id, 
					AES_ENCRYPT('some test data some test data some test data', 's73kg9dk*%FW&72MV.<SLAo9d9!FDSx~'),
					$dt, 0, NULL, 1)";
			
			$this->db->query($sql);
			echo $this->db->_error_message();
		}
		*/

		/*
		for($i=0; $i<20000; $i++)
		{
			$task_id = rand(1,1000);
			$tag_id = rand(1,300);
			$this->db->query("INSERT IGNORE INTO task_tag VALUES(null, $task_id, $tag_id) ");
			echo $this->db->_error_message();
		}
		*/
		
		/*
		for($i=0; $i < 300; $i++)
		{
			$name = 'tag-'.($i+1);
			$this->db->query("INSERT IGNORE INTO tag VALUES($i, '$name') ");
			echo $this->db->_error_message();
		}
		*/

		echo 'loading finished...';
	}
}